package com.me.batm.tweens;

import aurelienribon.tweenengine.TweenAccessor;

import com.badlogic.gdx.math.Vector2;
import com.me.batm.models.Target;

public class TargetAccessor implements TweenAccessor<Target>{
	public static int TARGET_MOVE = 1;
	public static int TARGET_FINISH_MOVE = 2;
	
	@Override
	public int getValues(Target target, int tweenType, float[] returnValues) {		
		returnValues[0] = target.shape.x;
		returnValues[1] = target.shape.y;
		return 2;
	}

	@Override
	public void setValues(Target target, int tweenType, float[] newValues) {
		if(tweenType == TARGET_MOVE){
			if(target.shape.x < newValues[0])target.direction = new Vector2(1f,0f);
			if(target.shape.x > newValues[0])target.direction = new Vector2(-1f,0f);
			if(target.shape.y < newValues[1])target.direction = new Vector2(0f,1f);
			if(target.shape.y > newValues[1])target.direction = new Vector2(0f,-1f);
			
			target.shape.x = newValues[0];
			target.shape.y = newValues[1];
			
			target.isWalking = true;
		}
		if(tweenType == TARGET_FINISH_MOVE){
			target.isWalking = false;
		}
	}

}
